<?php

use yii\db\Migration;

/**
 * Handles the creation of table `article`.
 */
class m170408_063831_create_article_table extends Migration
{
    /**
     * @inheritdoc
     */
    public function up()
    {
        $this->createTable('article', [
            'id' => $this->primaryKey()->comment("文章序号"),
            'title' => $this->string(50)->comment("文章标题"),
            'content' => $this->text()->comment("文章内容"),
            'tag' => $this->integer()->comment('标签'),
            'status' => $this->smallInteger()->comment('状态'),
            'create_time' => $this->date()->comment('创建时间'),
            'update_time' => $this->date()->comment('修改时间'),
            'author_id' => $this->integer()->comment("作者ID"),
            'is_deleted' => $this->integer()->comment('是否删除')
        ]);
        $this->addForeignKey('FK_author_id','article','author_id','user','id');
        $this->addForeignKey('FK_status','article','status','article_status','id');
    }

    /**
     * @inheritdoc
     */
    public function down()
    {
        $this->dropTable('article');
    }
}
